package Book;

import com.sun.deploy.panel.ITreeNode;

import java.util.*;

public class TestBook {
    public static void main(String[] args) {
        Book book1=new Book("斗罗大陆",45.12);
        Book book2=new Book("斗破苍穹",63.12);
        Book book3=new Book("武炼巅峰",78.45);
        Book book4=new Book("大主宰",287.5);
        Book book5=new Book("西游记",85.52);
        List<Book> list=new LinkedList<>();
        list.add(book1);
        list.add(book2);
        list.add(book3);
        list.add(book4);
        list.add(book5);
        Collections.sort(list);
        Iterator<Book> it=list.iterator();
        System.out.println("\t\t图书列表");
        System.out.println("图书名称\t\t"+"图书价格");
        while (it.hasNext()){
            Book book=it.next();
            System.out.println(book.getName()+"\t\t"+book.getPrice());
        }
        System.out.println("==================");
        Book book6=new Book("大主宰",287.5);
        System.out.println("\t重复的图书有：");
        System.out.println("图书名称\t\t"+"图书价格");
        for (int i=0;i<list.size();i++){
            String name=(String)list.get(i).getName();
            if (book6.getName()==name){
                System.out.println(list.get(i).getName()+"\t\t"+list.get(i).getPrice());
            }
        }
    }
}

